package com.example;

/**
 * 动物类，父类
 * 继承Object类
 */
public class Animal {
    public int a;
    private String name;
    private int age;

    public Animal() {
    }

    /* 父类的带参数构造方法不能被直接继承 */
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void catching() {
        System.out.println("动物嚎叫");
    }

    /* 重写父类的方法，覆盖父类方法的逻辑 */
    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}